package com.xzl.shop.model;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
public class Goods2 {
    private Integer id;
    private String name;
    private Integer amount;
    private Double price;
    private Integer type;
    private String url;
    private Integer sale;
    private Timestamp createTime;
    private Integer pageNum = 1;
    private Integer pageSize = 3;
    public Map<String, String> toHash(){
        Map<String, String> map = new HashMap<>();
        map.put("id",id.toString());
        map.put("name",name);
        map.put("url",url==null?"":url);
        map.put("price",price.toString());
        map.put("amount",amount.toString());
        return map;
    }
    public boolean set(List<String> list){
        if(list==null||list.size()!=5) return false;
        id = Integer.parseInt(list.get(0));
        name = list.get(1);
        price = Double.parseDouble(list.get(2));
        amount = Integer.parseInt(list.get(3));
        url = list.get(4);
        return true;
    }
}
